package com.houtai.eduservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.houtai.eduservice.entity.EduVideo;
import com.houtai.eduservice.entity.StuRead;
import com.houtai.eduservice.mapper.StuReadMapper;
import com.houtai.eduservice.service.StuReadService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lin
 * @since 2022-12-14
 */
@Service
public class StuReadServiceImpl extends ServiceImpl<StuReadMapper, StuRead> implements StuReadService {

    @Override
    public String getUrl(Integer id) {
        String url = "";
        QueryWrapper<StuRead> wrapperRead = new QueryWrapper<>();
        wrapperRead.eq("id", id);
        wrapperRead.select("readUrl");
        List<StuRead> stuRead = baseMapper.selectList(wrapperRead);

        // List<EduVideo>变成List<String>
        List<String> videoIds = new ArrayList<>();
        for (int i = 0; i < stuRead.size(); i++) {
            StuRead stuRead1 = stuRead.get(i);
            url = stuRead1.getReadUrl();
        }
        return url;
    }
}
